"""
进度 VO
"""

from models import (
    VOBase,
    VOPage,
)
from models.other import ProcessHistory
from utils.data_utils.special import ObjectIdStr
from utils.mock_utils import Demo
from utils.validator_utils.pydantic_validator.field import (
    CharField,
    IntegerField,
    ListField,
    NormalField,
)


class ProcessHistoryVO(ProcessHistory):
    """ 进度 | 历史记录 | VO """

    update_time: str = CharField(..., title="更新时间", min_length=23, max_length=23, examples=[Demo.dt_str_full])


class ProcessListVO(VOBase):
    """ 进度 | 列表 | VO """

    process_id: ObjectIdStr = CharField(..., title="进度 ID（ObjectId 字符串）", examples=[Demo.id])

    create_time: str = CharField(..., title="创建时间", min_length=19, max_length=19, examples=[Demo.dt_str])
    percent: int = IntegerField(..., title="进度百分比", min_value=0, max_value=100)
    result: dict = NormalField(..., title="结果")
    status_label: str = CharField(..., title="状态名称", min_length=2, max_length=32)
    task_label: str = CharField(..., title="任务标签", min_length=2, max_length=32)
    update_time: str = CharField(..., title="更新时间", min_length=19, max_length=19, examples=[Demo.dt_str])


class ProcessDetailVO(ProcessListVO):
    """ 进度 | 详情 | VO """

    exception_msg: str = CharField(..., title="异常信息", max_length=1024)
    history: list[ProcessHistoryVO] = ListField(default_factory=list, title="历史记录")


class ProcessListPage(VOPage[ProcessListVO]):
    """ 进度 | 列表 | 分页 """
